<?php
if (!$_SESSION['sid']) exit('Permission Denied!');
include '../../common/header.html';
include '../../common/left.html';
include '/var/www/html/wx/wechat/iwx.php';
//include_once '/var/www/html/new/com.inc.php';
use \LaneWeChat\Core\Ext;
use \LaneWeChat\Core\WeChatOAuth;
define("WECHAT_APPID", 'wxd72be21f7455640d');

$sql = "select id,fid,account,fromusername,createtime,lastlogin,verifycode
        from uu_wx_member_pft where fid={$_SESSION['sid']}";
$GLOBALS['le']->query($sql);
$row = array();
while($row=$GLOBALS['le']->fetch_assoc()){
    $r[$row['fromusername']] = $row;
}
if(count($r))
foreach ($r as $k => $v) {
    $a = \LaneWeChat\Core\UserManage::getUserInfo($k);
    if($a['subscribe']==1)
        $r[$k] = array_merge($r[$k],$a);
}

?>
<style>
	.scan-qr-bind{text-align:center;cursor:pointer;margin-top:20px;}
	.scan-qr-bind p{font-size:16px;line-height:35px;}
	.fans-bind{margin-top:20px;}
	.fans-bind h3{font-size:16px;line-height:35px;}
    img{ border:1px solid #ddd; padding:2px;}
    .wx_img {width: 40px; height: 40px;}
    .img-qr{width: 120px;height: 120px;}
    .tb{width:100%;}
	.tb th{background-color:#F2F2F2;font-size:14px;}
    .tb th,.tb td{border:1px solid #ddd;line-height:35px;padding-left:10px;}
	
</style>
<div class="r_content">
    <!-- 扫码关注绑定模块 -->
    <div class="scan-qr-bind">
      
        <img src="http://api.k780.com:88/?app=qr.get&amp;data=http://503334.12301.cc/wx/html/bind_by_qr.php?state=<?=$_SESSION['sid'].'z'.$_SESSION['account']?>&amp;level=H&amp;size=8" class="img-qr">
		<p>扫描二维码即可快速绑定平台账号</p>
	</div>
    <div class="fans-bind">
        <h3>已绑定账号列表</h3>
        <table class="tb">
            <thead>
            <tr>
                <th>头像</th>
                <th>昵称</th>
                <!--            <th>性别</th>-->
                <!--            <th>fid</th>-->
                <th>平台账号</th>
                <th>创建时间</th>
                <th>最后登录时间</th>
                <th>是否接收通知</th>
            </tr>
			
            </thead>
            <tbody id="tbody">
            <?php if(count($r)):?>
            <?php foreach ($r as $k => $v):?>
            <tr data-fid="<?=$v['fid']?>">
                <td><img src="<?=$v['headimgurl']?>" alt="<?=$v['nickname']?>" class="wx_img"></td>
                <td class="nickname"><?=isset($v['nickname']) ? $v['nickname'] : '该用户已取消关注'?></td>
                <!--            <td>--><?//=$v['sex']==1?'男':'女'?><!--</td>-->
                <!--            <td>--><?//=$v['fid']?><!--</td>-->
                <td><?=$v['account']?></td>
                <td><?=date("Y-m-d H:i:s",$v['createtime'])?></td>
                <td><?=$v['lastlogin']?></td>
                <td>
                    <input class="handler"
                       type="radio"
                       name="verifycode"
                       data-nickname="<?=$v['nickname']?>"
                       data-openid="<?=$v['fromusername']?>"
                    <?=$v['verifycode']==1 ? 'checked' : ''?>
                           value="<?=$v['id']?>"/>
                </td>
                <?endforeach?>
                <?php endif;?>
            </tbody>
        </table>
    </div>

</div>
<script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
<script>
    $("#tbody").on('click', '.handler', function(){
        var nickname = $(this).data('nickname');
        if (!confirm('确定要设置【'+nickname+'】为接收通知的账号吗？')) return false;
        var id = $(this).val(),
            fromusername = $(this).data('openid');
        $.post('//www.12301.cc/module/wechat/ichat.php', {
                fromusername:fromusername,
                id:id,action:'verifycode'
            }, function(json){
                alert(json.msg);
            },'json');
    });
</script>
<?php include '../../common/footer.html';?>